package A9_JUC辅助类;

import java.util.concurrent.CountDownLatch;

/**
 *
 *  经典例子：放学关门、一起坐车
 * @Author: KingWang
 * @Date: 2021/5/23
 * @Desc:
 **/
public class CountDownLatchDemo {

    public static void main(String[] args) throws InterruptedException {

        CountDownLatch countDownLatch = new CountDownLatch(10);
        for (int i = 0; i < 10 ; i++) {

            new Thread(() -> {
                System.out.println(Thread.currentThread().getName() + "\t 等车");
                countDownLatch.countDown();
//                System.out.println(countDownLatch.getCount());
            },String.valueOf(i)).start();

        }

        countDownLatch.await();
        System.out.println(Thread.currentThread().getName() + "\t 车开了");


    }
}
